home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / EPISODE / JKM_PCG.GOO / cog_s1l3_securitycam.cog < prev    next >
Text File  |  1998-02-25  |  2KB  |  73 lines

  1. # S1L3_SecurityCam.cog
  2. #
  3. # Security camera cog.  Modification of 00_securitycam.cog.  Modified by Chris Klie.
  4. #
  5. # [YB/CK]
  6. #
  7. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  8.  
  9. symbols
  10. thing       camera                        //the camera object
  11. thing        GhostCamera                        //corresponding ghost camera object
  12. int         player                        local
  13. int         triggerNum=10000              local
  14. int        triggerAlive            local
  15. int        triggerDead                local
  16. int         active=0                      local
  17. int        CameraNumber=1                    //1 thru 11 don't use the same number twice
  18. int        PulseValue=1                    //how often the camera checks for the player
  19. int        WarmUpTime=1                    //how long the camera takes to warm up
  20. int        IAmSleeping=0            local
  21. int        IAmDead=0                local
  22. vector      cameraPos                     local
  23. message     startup
  24. message        killed
  25. message     pulse
  26. message    activated
  27. message    timer
  28. message    entered
  29. message    trigger
  30. sector    GoSector                linkid=1    //camera warms up when player enters
  31. end
  32.  
  33. code
  34. startup:
  35.    triggerNum=(triggerNum+CameraNumber);
  36.    if(PulseValue<1) PulseValue=1;
  37.    if(PulseValue>5) PulseValue=5;
  38.    if(triggerNum>10011) triggerNum=0;
  39.    if(triggerNum<10001) triggerNum=0;
  40.    if(triggerNum==0) return;
  41.    triggerAlive=(triggerNum+11);                
  42.    triggerDead=(triggerNum+22);
  43.    SendTrigger(-1,triggerAlive,camera,0,0,0);
  44.    player=GetLocalPlayerThing();
  45.    cameraPos=GetThingPos(camera);
  46.    SetPulse(PulseValue);
  47.    return;
  48. killed:
  49.    Active=0;
  50.    SetPulse(0.0);
  51.    SendTrigger(-1,triggerDead,camera,0,0,0);
  52.    return;
  53. pulse:
  54.    if(!Active) return;  
  55.    if((FirstThingInView(camera,60,5.0,0x400)!=-1)&&(IAmSleeping==0))
  56.    {
  57.       if(VectorDist(cameraPos,GetThingPos(player))<2.0) SendTrigger(-1,triggerNum,camera,0,0,0);
  58.    }
  59.    return;
  60. trigger:
  61.    if(GetSourceRef()==triggerDead) IAmDead=1;
  62.    return;
  63. entered:
  64.    if((GetSenderID()==1)&&(IAmSleeping==0)&&(IAmDead==0)&&(Active==0))
  65.    {
  66.     IAmSleeping=1;
  67.     Sleep(WarmUpTime);
  68.     Active=1;
  69.     IAmSleeping=0;
  70.    }
  71.    return;                    
  72. end
  73.